package GUI;

import javax.swing.JFrame;
import javax.swing.JPanel;
import util.ResourceManager;

public class JanelaAuxiliar extends JFrame {

	private static final long serialVersionUID = 1L;
	
	private ResourceManager res;
	
	private JPanel pPrincipal = null;
	private PaneSobre pSobre = null;
	private PaneAjuda pAjuda = null;
	private PaneBemVindo pBemVindo = null;
	
	public JanelaAuxiliar(ResourceManager res) {
		super();
		this.res = res;
		initialize();
	}
	
	private void hideAllPanels() {
		getPaneSobre().setVisible(false);
		getPaneAjuda().setVisible(false);
		getPaneBemVindo().setVisible(false);
	}

	private void initialize() {
		this.setIconImage(res.getImage("AppIcon.png").getImage());
		this.setSize(300, 365);
		this.setTitle("Janela Auxiliar");
		this.setContentPane(getPanePrincipal());
		this.setResizable(false);
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		this.setLocationRelativeTo(null);
	}
	
	private JPanel getPanePrincipal() {
		if (pPrincipal == null) {
			pPrincipal = new JPanel();
			pPrincipal.setLayout(null);
			pPrincipal.setBackground(ResourceManager.corBranca1);
			pPrincipal.add(getPaneSobre());
			pPrincipal.add(getPaneAjuda());
			pPrincipal.add(getPaneBemVindo());
		}
		return pPrincipal;
	}
	
	private PaneSobre getPaneSobre() {
		if(pSobre == null) {
			pSobre = new PaneSobre(res);
		}
		return pSobre;
	}
	
	private PaneAjuda getPaneAjuda() {
		if(pAjuda == null) {
			pAjuda = new PaneAjuda(res);
		}
		return pAjuda;
	}
	
	private PaneBemVindo getPaneBemVindo() {
		if(pBemVindo == null) {
			pBemVindo = new PaneBemVindo(res);
		}
		return pBemVindo;
	}
	
	public void executarFuncao(String funcao) {
		
		this.setVisible(false);
		hideAllPanels();
		
		if(funcao.equals("Ajuda")) {
			this.setSize(470, 365);
			this.setTitle("Ajuda");
			getPaneAjuda().setVisible(true);
			
		} else if(funcao.equals("Bem-Vindo")) {
			this.setSize(470, 365);
			this.setTitle("Bem-Vindo!");
			getPaneBemVindo().setVisible(true);
			
		} else if(funcao.equals("Sobre")) {
			this.setSize(290, 380);
			this.setTitle("Sobre o Sistema Gerente Fisio");
			getPaneSobre().setVisible(true);
		}	
	
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
}
